package encaps.utils.rendering;

import static encaps.utils.html.HTML.*;
import encaps.utils.html.HTMLElement;
import encaps.utils.html.HTMLElementSequence;

public class TextAreaFactory extends TextControlFactory {

    @Override
    protected HTMLElement createTextControl(String name, String value) {
        HTMLElementSequence result = new HTMLElementSequence();
        HTMLElement control = new HTMLElement(TEXTAREA);
        control.addAttribute(COLS, DEFAULT_COLS);
        control.addAttribute(ROWS, DEFAULT_ROWS);
        control.addAttribute(NAME, name);

        if (value == null) {
            control.addContent("");
        } else {
            control.addContent(value);
        }
        result.addContent(HTMLElement.createBr());
        result.addContent(control);
        return result;
    }
}
